**************************************
**************************************
* Replication file for Lacina, B and Gleditsch, N.P. 2013
* �The waning of war is real: A response to Gohdes and Price,� Journal of Conflict Resolution
**************************************
**************************************

use "WaningWarReplicationData.dta", clear

notes

***Figure One***

twoway (line risk_lp year, lp(solid) lc(gs10))(line risk_hp year, lp(solid) lc(gs0)), ///
ytitle("Deaths per 100,000") title("") note("") legend(off) ///
xtitle("Year") scheme(lean2) ylabel(,nogrid) xscale(range(1945 2000))

***Figure 2(a)***

twoway ///
(lowess risk_lp year, bw(0.5) m(none) lp(shortdash) lc(gs4)) ///
(lowess risk_lp year, bw(0.8) m(none) lp(dash) lc(gs8)) ///
(line risk_lp year, lp(solid) lc(gs13)), ///
ytitle("Deaths per 100,000") title("") ///
legend(subtitle("Bandwidth") pos(6) r(1) order(1 "0.5" 2 "0.8")) ///
xtitle("Year") scheme(lean2) ylabel(,nogrid) xscale(range(1945 2000))
graph export "lowess_riskl.png", width(3000) replace

***Figure 2(b)***

twoway ///
(lowess risk_hp year, bw(0.5) m(none) lp(shortdash) lc(gs4)) ///
(lowess risk_hp year, bw(0.8) m(none) lp(dash) lc(gs8)) ///
(line risk_hp year, lp(solid) lc(gs13)), ///
ytitle("Deaths per 100,000") title("") ///
legend(subtitle("Bandwidth") pos(6) r(1) order(1 "0.5" 2 "0.8")) ///
xtitle("Year") scheme(lean2) ylabel(,nogrid) xscale(range(1945 2000))
graph export "lowess_riskh.png", width(3000) replace

window manage close graph _all

***Table 1, OLS***

*Model 1
reg risk_lo time, vce(robust)

*Model 2
reg risk_lo time if year<=1997, vce(robust)

*Model 3
reg risk_lo time if year>1950 & year<=1997, vce(robust)

*Model 4
reg risk_hi time, vce(robust)

*Model 5
reg risk_hi time if year<=1997, vce(robust)

*Model 6
reg risk_hi time if year>1950 & year<=1997, vce(robust)

*Model 7
reg risk_m time if year>1950 & year<=1997, vce(robust)

***Table 1, Kendall's Rank Test***

*Model 1
ktau risk_low year

*Model 2
ktau risk_low year if year<=1997

*Model 3
ktau risk_low year if year<=1997 & year>1950

*Model 4
ktau risk_hig year

*Model 5
ktau risk_hi year if year<=1997

*Model 6
ktau risk_hi year if year<=1997 & year>1950

*Model 7
ktau risk_m time if year>1950 & year<=1997

*Calculations for Figures 3-5

keep year world* time

save "popyrs.dta", replace

postutil clear
set more off
postfile results_cutoff sample cutoff tau_a p beta se p_ols using "fig3to5results.dta", replace

use "WaningWarReplicationData.dta", clear

forval i = 1946(1)2008 {

use "PRIObd3original.dta", clear

*1 = low estimates before cutoff, then high

gen bdead_1=bdeadl

replace bdead_1=bdeadh if year>=`i'

*3 = best estimates where available. Otherwise low estimates before cutoff, then high

gen bdead_3=bdead_1

replace bdead_3=bdeadb if bdeadbes!=-999

*4 = low estimates before cutoff year, best estimates after (high estimate if best estimate is missing)

gen bdead_4=bdead_1

replace bdead_4=bdeadb if bdeadbes!=-999 & year>=`i'

* 5 = best estimates before cutoff year (low estimate if best estimate is missing), high estimates after 

gen bdead_5=bdead_1

replace bdead_5=bdeadb if bdeadbes!=-999 & year<`i'

collapse (sum) bdead*, by(year)

merge 1:1 year using "popyrs.dta", nogen

foreach x in 1 3 4 5 {

gen risk_`x'=(bdead_`x'/world_population_lag)

replace risk_`x'=(bdead_`x'/world_populationpwt_lag) if world_population_lag==.

qui: ktau risk_`x' time

local tau=r(tau_a)

local p=r(p)

qui: reg risk_`x' time

local pweight = (2 * ttail(e(df_r), abs(_b[time]/_se[time])))

post results_cutoff (`x') (`i') (`tau') (`p') (_b[time]) (_se[time]) (`pweight')

}
}

postclose results_cutoff

use "fig3to5results.dta", clear

**Figure 3**

gen lb = beta - invnorm(0.95)*se
gen ub = beta + invnorm(0.95)*se

twoway (line beta cutoff if sample==1) ///
(line lb cutoff if sample==1, lp(dash)) ///
(function y=0,range(1940 2020) lp(solid) lc(gs10)) ///
(line ub cutoff if sample==1, lp(dash)), ///
ytitle("OLS coefficient estimate") title("") note("") legend(off) ///
xtitle("Cutoff year for low estimates") scheme(lean2) ylabel(,nogrid) xscale(range(1945 2009))

**Figure 4a**

twoway (line p_ols cutoff if sample==1, lp(solid) sort) ///
(line p_ols cutoff if sample==3, lp(solid) lc(gs7) sort) ///
(function y=0.05, range(1940 2020) lp(shortdash) lc(gs10) lwidth(vthin)) ///
(function y=0.1, range(1940 2020) lp(shortdash) lc(gs10) lwidth(vthin)) ///
, ///
ytitle("p-value") title("") note("") ///
xtitle("Cutoff year") scheme(lean2) xscale(range(1945 2009)) ///
yscale(log) ///
ylabel(1e-7 1e-6 1e-5 1e-4 1e-3 0.001 0.01 0.1 1, nogrid) ytick(0 0.0000001 0.000001 0.00001 0.0001 0.001 0.01 0.1 1) ///
legend(pos(6) r(3) order(1 "Low estimates prior to the cutoff year, high estimates thereafter" 2 "Best or low estimates prior to the cutoff year," "best or high estimates thereafter"))

**Figure 4b**

twoway (line p cutoff if sample==1, lp(solid) sort) ///
(line p cutoff if sample==3, lp(solid) lc(gs7) sort) ///
(function y=0.05, range(1940 2020) lp(shortdash) lc(gs10) lwidth(vthin)) ///
(function y=0.1, range(1940 2020) lp(shortdash) lc(gs10) lwidth(vthin)) ///
, ///
ytitle("p-value") title("") note("") ///
xtitle("Cutoff year") scheme(lean2) xscale(range(1945 2009)) ///
yscale(log) ///
ylabel(1e-8 1e-7 1e-6 1e-5 1e-4 1e-3 0.001 0.01 0.1 1, nogrid) ytick(0 0.00000001 0.0000001 0.000001 0.00001 0.0001 0.001 0.01 0.1 1) ///
legend(pos(6) r(3) order(1 "Low estimates prior to the cutoff year, high estimates thereafter" 2 "Best or low estimates prior to the cutoff year," "best or high estimates thereafter"))

**Figure 5a**

twoway (line p_ols cutoff if sample==4, lp(solid) sort) ///
(line p_ols cutoff if sample==5, lp(solid) lc(gs7) sort) ///
(function y=0.05, range(1940 2020) lp(shortdash) lc(gs10) lwidth(vthin)) ///
(function y=0.1, range(1940 2020) lp(shortdash) lc(gs10) lwidth(vthin)) ///
, ///
ytitle("p-value") title("") note("") ///
xtitle("Cutoff year") scheme(lean2) xscale(range(1945 2009)) ///
yscale(log) ///
ylabel(1e-7 1e-6 1e-5 1e-4 1e-3 0.001 0.01 0.1 1, nogrid) ytick(0 0.0000001 0.000001 0.00001 0.0001 0.001 0.01 0.1 1) ///
legend(pos(6) r(2) order(1 "Low estimates prior to the cutoff year, best estimates thereafter" 2 "Best estimates prior to the cutoff year, high estimates thereafter"))

**Figure 5b**

twoway (line p cutoff if sample==4, lp(solid) sort) ///
(line p cutoff if sample==5, lp(solid) lc(gs7) sort) ///
(function y=0.05, range(1940 2020) lp(solid) lc(gs10) lwidth(vthin)) ///
(function y=0.1, range(1940 2020) lp(solid) lc(gs10) lwidth(vthin)) ///
, ///
ytitle("p-value (Kendall's tau-a)") title("") note("") ///
xtitle("Cutoff year") scheme(lean2) xscale(range(1945 2009)) ///
yscale(log) ///
ylabel(1e-7 1e-6 1e-5 1e-4 1e-3 0.001 0.01 0.1 1, nogrid) ytick(0 0.0000001 0.000001 0.00001 0.0001 0.001 0.01 0.1 1) ///
legend(pos(6) r(2) order(1 "Low estimates prior to the cutoff year, best or high estimates thereafter" 2 "Best or low estimates prior to the cutoff year, high estimates thereafter"))

